﻿using com.guojin.core.io.message;
using com.guojin.mj.net;
using com.guojin.mj.net.message.login;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CreateRoomController
{
    private static CreateRoomController instance;
    public static CreateRoomController GetInstance()
    {
        if (instance == null)
        {
            instance = new CreateRoomController();
        }
        return instance;
    }

    public string RoomName = "";
    public string EmpowerTakeIn = "false";
    public string AutoCompute = "false";
    public string VieForZhuang = "false";
    public string MaxPlayerCount = "6";
    public string SameNiu = "0";
    public string OneTimesBet = "0";
    public string CreateRoomType = "0";            
    public string BotScore = "2";
    public string MinTakeInScore = "200";
    public string MaxTakeInScore = "4";
    public string ServiceCharge = "40";
    public string RoomExistenceTime = "30";
    public string ClubOrLianMengID = "0";
    public string mingpai = "false";

    //发送创建房间消息
    public void SendCreatRoomMsg70()
    {
        //0代表普通房间  1代表代开房 2代表俱乐部房间
        MessageManager.GetInstance().SendMsg70(AppendRuleToCreateRoomMsg());  
    }

    //创建房间添加规则
    public List<OptionEntry> AppendRuleToCreateRoomMsg()
    {
        var optionList = new List<OptionEntry>();
        optionList.Add(OptionEntry.create(GameController.RoomName, RoomName));
        optionList.Add(OptionEntry.create(GameController.EmpowerTakeIn, EmpowerTakeIn));
        optionList.Add(OptionEntry.create(GameController.AutoCompute, AutoCompute));
        optionList.Add(OptionEntry.create(GameController.VieForZhuang, VieForZhuang));
        optionList.Add(OptionEntry.create(GameController.MaxPlayerCount, MaxPlayerCount));
        optionList.Add(OptionEntry.create(GameController.SameNiu, SameNiu));
        optionList.Add(OptionEntry.create(GameController.OneTimesBet, OneTimesBet));
        optionList.Add(OptionEntry.create(GameController.CreateRoomType, CreateRoomType));
        optionList.Add(OptionEntry.create(GameController.BotScore, BotScore));
        optionList.Add(OptionEntry.create(GameController.MinTakeInScore, MinTakeInScore));
        optionList.Add(OptionEntry.create(GameController.MaxTakeInScore, MaxTakeInScore));
        optionList.Add(OptionEntry.create(GameController.ServiceCharge, ServiceCharge));
        optionList.Add(OptionEntry.create(GameController.RoomExistenceTime, RoomExistenceTime));
        optionList.Add(OptionEntry.create(GameController.ClubOrLianMengID, ClubOrLianMengID));
        optionList.Add(OptionEntry.create("mingpai", mingpai));
        Debug.Log(RoomName);
        Debug.Log(EmpowerTakeIn);
        Debug.Log(AutoCompute);
        Debug.Log(MaxPlayerCount);
        Debug.Log(VieForZhuang);
        Debug.Log(SameNiu);
        Debug.Log(OneTimesBet);
        Debug.Log(CreateRoomType);
        Debug.Log(BotScore);
        Debug.Log(MinTakeInScore);
        Debug.Log(MaxTakeInScore);
        Debug.Log(ServiceCharge);
        Debug.Log(RoomExistenceTime);
        Debug.Log(ClubOrLianMengID);
        return optionList;
    }

    //接收创建房间消息
    public void OnReceiveMsg71(string msg, Message data)
    {
        Debug.Log("收到创建房间信息");
        var crr = (CreateRoomRet)data;
        if (crr.result)
        {
            MessageManager.GetInstance().SendMsg76(crr.roomID);             
        }
    }
}
